MAX_size=4
class SqQueue:
    def __init__(self):
        self.date=[None]*MAX_size
        self.front=-1
        self.rear=-1
    def empty(self):
        return self.front==self.rear
    def push(self,e): 			#元素e进队
        assert not self.rear==MAX_size-1   	#检测队满
        self.rear+=1
        self.data[self.rear]=e

    def pop(self):  # 出队元素
        assert not self.empty()  # 检测队空
        self.front += 1
        return self.data[self.front]

    def gethead(self):  # 取队头元素
        assert not self.empty()  # 检测队空
        return self.data[self.front + 1]
    def size(self):
        return len(self.queue)
queue=SqQueue()
while True:
    print("----------------------")
    print("1. 入队")
    print("2. 出队")
    print("3. 查看队首元素")
    print("4. 查看队列大小")
    print("5. 判断队列是否为空")
    print("0. 退出程序")

    choice = input("请选择操作: ")

    if choice == "1":
        item = input("请输入要入队的元素: ")
        queue.push(item)
        print("元素", item, "已入队")
    elif choice == "2":
        item = queue.pop()
        print("元素", item, "已出队")
    elif choice == "3":
        item = queue.gethead()
        print("队首元素为:", item)
    elif choice == "4":
        size = queue.size()
        print("队列大小为:", size)
    elif choice == "5":
        is_empty = queue.empty()
        print("队列是否为空:", is_empty)
    elif choice == "0":
        break
    else:
        print("无效的操作，请重新选择")
